<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:84:"E:\phpstudy2016\WWW\shopsum\public/../application/admin\view\index\dictionaries.html";i:1520940404;s:57:"E:\phpstudy2016\WWW\shopsum\application\public\admin.html";i:1520912952;}*/ ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数据字典-<?php echo \think\Config::get('title'); ?></title>
    <link rel="stylesheet" href="../../../../public/static/public/boo3/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="__PUBLIC__/index/css/sytle.css">
    <script src="__PUBLIC__/public/js/jquery-2.1.4.min.js"></script>
    <script src="__PUBLIC__/public/js/vue.min.js"></script>
    <script src="__PUBLIC__/public/js/jquery.transit.js"></script>
    <script src="__PUBLIC__/public/js/jquery.timers-1.2.js"></script>
    <script src="__PUBLIC__/public/layer-v3.1.1/layer/layer.js"></script>
    <style>
        #container{
            padding: 0 30px;
        }
        nav{
            background-color: #f5f5f5;
            padding: 10px 20px;
            z-index: 99;
            margin-bottom: 15px;
        }
        @media screen and (max-width: 800px) {
            nav{
                display: none;
            }
        }
    </style>
    <script>
        var DINDEX = '/admin/index';
        var DUSER = '/admin/user';
        var DADMIN = '/admin';
        var DJOURNALISM = '/admin/journalism';
        var DCOUNT = '/admin/count';
        //页面
        function yeMian(url,fn = 1,this_json = {title:'信息',area:['400px','450px']}) {

            var index = layer.open($.extend({type:2,content:url,end:function () {
                    if(typeof fn != 'number' ){
                        fn();
                    }
                }},this_json));
        }

        //看图
        function loock_img(url) {
            url = url.data('img');
            if((typeof url) != 'string'){
                layer.msg('没有数据查看',{icon:2});
                return;
            }
            layer.open({
                type:2,
                title:false,
                closeBtn:false,
                area:['100%','100%'],
                content:"<?php echo url('loock/index',['on'=>'true']); ?>?url="+url
            })
        }
    </script>
    
<link rel="stylesheet" href="__PUBLIC__/admin/css/index.dictionaries.css">


</head>
<body>

<nav>
       <small><i class="fa fa-institution"></i></small> 首页 > <?php echo \think\Config::get('this_user_name'); if(\think\Request::instance()->param('on') == 'true'): ?>
       <a href="javascript:;" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));"  title="关闭当前页面" class="btn btn-xs btn-default fa-pull-right " style="margin-left: 10px"><i class="fa fa-close"></i></a>
        <?php endif; ?>
    <a href="javascript:location.reload();" title="刷新" class="btn btn-xs btn-success fa-pull-right"><i class="fa fa-refresh"></i></a>
</nav>

<div id="container">
    <div class="col-xs-6 col-xs-offset-3">

    </div>

    <div class="clearfix"></div>
    <div style="height: 20px;"></div>
    <div class="table-responsive" id="header">
        <table class="table table-bordered table-hover" v-cloak>
           <thead>
               <tr class="active">
                   <th colspan="7" class="text-left">
                       <a href="javascript:;" @click="addData()" class="btn btn-info btn-sm"><i class="fa fa-plus"></i> <?php echo lang('添加'); ?></a>
                       <span class="fa-pull-right">总 <strong>{{list.length}}</strong> 条</span>
                   </th>
               </tr>
               <tr class="active">
                   <th width="5%">编号</th>
                   <th width="10%">编码</th>
                   <th width="10%">名称</th>
                   <th width="20%">备注</th>
                   <th width="20%">创建时间</th>
                   <th width="30%">用途</th>
                   <th width="5%" class="text-center">操做</th>
               </tr>
           </thead>
            <tbody>
                <tr v-for="(key,index) in list">
                    <td>{{index+1}}</td>
                    <td><input type="text" v-model="key.code" @change="up('code',key.code,key.id)"></td>
                    <td><input type="text" v-model="key.name" @change="up('name',key.name,key.id)"></td>
                    <td><input type="text" v-model="key.memo" @change="up('memo',key.memo,key.id)"></td>
                    <td>{{key.addtime}}</td>
                    <td><input type="text" v-model="key.title"  @change="up('title',key.title,key.id)"></td>
                    <td class="text-center">
                        <a href="javascript:;" @click="de(key.id,index)" class="btn btn-xs" title="删除"><i class="fa fa-trash-o"></i></a>
                    </td>
                </tr>
            </tbody>

        </table>
        <div class="alert">
            <h5>书写规范提示：</h5>
            开头两位数，代表类表。
        </div>
    </div>
</div>


</body>
</html>

<script>
    var app = new Vue({
        el:'#header',
        data:{
            list:[]
        }
    });
    get_data();
    //获取数据
    function get_data() {
        $.get(DINDEX+'/dictionaries.html',function (da) {
            app.list = da;
        });
    }

    //内容改变事件
    app.up = (name,val,id)=>{
        $.post(DINDEX+'/up_dictionaries',{name:name,val:val,id:id},function (da) {
            if(da){
                layer.msg('修改成功',{icon:1,offset:'rb'});
            }
            else {
                layer.msg('修改失败',{icon:2,offset:'rb'});
                get_data();
            }
        });
    }

    //删除内容
    app.de = (id,index)=>{

        var queren = layer.confirm('确定要删除',{icon:0},function () {
            layer.close(queren);
            app.list.splice(index,1);
            $.post(DINDEX+'/de_dictionaries',{id:id},function (da) {
                if(da){
                    layer.msg('删除成功',{icon:1,offset:'rb'});
                }
                else {
                    layer.msg('删除失败',{icon:2,offset:'rb'});
                    get_data();
                }
            });
        });

    }

    //添加内容
    app.addData=()=>{
        yeMian(DINDEX+'/add_dictionaries',function () {
            get_data();
        });
    }
</script>
